Skip to content

MDEV-39169: Replace deprecated network functions with modern POSIX equivalents#4856

Merged
gkodinov merged 1 commit into
MariaDB:mainfrom
FaramosCZ:resolveip_ipv6
Jul 16, 2026
Merged

MDEV-39169: Replace deprecated network functions with modern POSIX equivalents#4856
gkodinov merged 1 commit into
MariaDB:mainfrom
FaramosCZ:resolveip_ipv6

Conversation

@FaramosCZ

Copy link
Copy Markdown
Contributor

resolveip: replace inet_aton/inet_addr, gethostbyname, gethostbyaddr, inet_ntoa with inet_pton, getaddrinfo, getnameinfo, inet_ntop.

These deprecated functions are IPv4-only and some are not thread-safe (gethostbyname, gethostbyaddr, and inet_ntoa use static internal buffers). The modernized code:

  • Adds IPv6 support for both forward and reverse lookups
  • Uses thread-safe APIs throughout
  • Eliminates the #ifdef WIN32 code path split (inet_pton works on both)
  • Removes the h_errno dependency (replaced by gai_strerror)
  • Uses AF_UNSPEC with getaddrinfo to return both IPv4 and IPv6 results
  • Preserves existing output format, exit codes, and special cases (Broadcast, Null-IP-Addr, Old-Bcast)

Bump version from 2.3 to 2.4 to reflect the API change.

Update Solaris library search in CMakeLists.txt from inet_aton to getaddrinfo since the old function is no longer referenced.

@gkodinov gkodinov added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label Mar 25, 2026
@gkodinov gkodinov changed the title Replace deprecated network functions with modern POSIX equivalents MDEV-39169: Replace deprecated network functions with modern POSIX equivalents Mar 25, 2026

@gkodinov gkodinov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution! This is a preliminary review.

LGTM. I've taken the liberty of filing a jira for the task.

Please stand by for the final review.

I'd also be nice to have some sort of testing for this. Maybe resolve some IPv6 IP or something?

@FaramosCZ
FaramosCZ force-pushed the resolveip_ipv6 branch 2 times, most recently from 70e52fc to 6333f1a Compare March 25, 2026 13:02

@raghunandanbhat raghunandanbhat left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FaramosCZ , thanks for the contribution.

I have a few suggestion-

  • please squash two commits into a single commit
  • ensure that commit message starts with the MDEV number, something like MDEV-39169:...
  • plus, issues I found in test (comments below).

Comment thread mysql-test/main/resolveip.test Outdated
Comment thread mysql-test/main/resolveip.test Outdated
Comment thread mysql-test/main/resolveip.test Outdated
@FaramosCZ
FaramosCZ marked this pull request as draft March 27, 2026 15:03
@FaramosCZ
FaramosCZ force-pushed the resolveip_ipv6 branch 4 times, most recently from e64c305 to dbd5f00 Compare March 28, 2026 08:58
@FaramosCZ
FaramosCZ marked this pull request as ready for review March 29, 2026 08:51
@FaramosCZ

Copy link
Copy Markdown
Contributor Author

I fixed all concerns you listed.
Let me know if anything else needs changing.

@raghunandanbhat raghunandanbhat left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FaramosCZ, looks good overall.

cases like ::, ::1, IPv4-mapped IPv6 addresses, etc seem to work fine. however, some test cases are "sneaky". please fix them.

Comment thread mysql-test/main/resolveip.test Outdated
@FaramosCZ
FaramosCZ marked this pull request as draft March 30, 2026 10:21
@FaramosCZ
FaramosCZ force-pushed the resolveip_ipv6 branch 5 times, most recently from b1399e9 to af57ebc Compare March 30, 2026 14:00
@FaramosCZ
FaramosCZ marked this pull request as ready for review March 30, 2026 16:02

@raghunandanbhat raghunandanbhat left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me. thank you @FaramosCZ for the contribution.

@gkodinov, I believe this needs go through QA/testing before we merge this.

@raghunandanbhat
raghunandanbhat dismissed their stale review March 31, 2026 06:06

test failure found in build bot - amd64-ubuntu-2204 & s390x-ubuntu-2204-debug

@gkodinov gkodinov assigned gkodinov and unassigned raghunandanbhat Apr 21, 2026
@gkodinov
gkodinov requested a review from elenst April 22, 2026 11:15
@gkodinov gkodinov assigned elenst and unassigned gkodinov Apr 22, 2026
@elenst
elenst requested review from mariadb-RameshSivaraman and removed request for elenst June 11, 2026 14:34
@gkodinov
gkodinov enabled auto-merge (rebase) July 15, 2026 07:47
@gkodinov
gkodinov disabled auto-merge July 15, 2026 07:47
@gkodinov
gkodinov enabled auto-merge (rebase) July 15, 2026 07:49
auto-merge was automatically disabled July 15, 2026 12:10

Rebase failed

@gkodinov
gkodinov enabled auto-merge (rebase) July 15, 2026 12:41
Replace inet_aton/inet_addr/gethostbyname/gethostbyaddr with
their modern POSIX equivalents inet_pton/getaddrinfo/getnameinfo.
This adds IPv6 support to resolveip and removes dependency on the
deprecated h_errno global.

Handle IPv6 unspecified address (::) as Null-IP-Addr, consistent
with existing IPv4 INADDR_ANY handling for 0.0.0.0.

Add MTR test covering IPv4/IPv6 reverse lookups, special
addresses, multiple arguments, mixed address types, and
invalid hostname handling.

Co-Authored-By: Claude AI <noreply@anthropic.com>
@gkodinov
gkodinov merged commit 7322a66 into MariaDB:main Jul 16, 2026
18 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements.

Development

Successfully merging this pull request may close these issues.

5 participants